#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPainter>
#include <QPoint>
#include <QMouseEvent>
#include <QProcess>
#include <QTimer>
#include <QRegularExpression>
#include <QRegularExpressionMatchIterator>
#include <QStringList>
#include <QIcon>
#include <QPixmap>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QRegExp>
#include <QDebug>

#define MENU_ITEM_OPEN_MONITOR 0 //打开Monitor
#define MENU_ITEM_EXIT_APPLICATION 1 //退出应用程式

namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void closeEvent(QCloseEvent *event);
    void mousePressEvent(QMouseEvent*);
    void mouseMoveEvent(QMouseEvent*);
    void mouseReleaseEvent(QMouseEvent*);
    QString ReadFile2String(QString);
    QString GetSizeInfo(qint64);
    void GetNetInformation();
    void GetFreeMemoryInfo();
    void SetSystemTray();
private slots:
    void GetInformation();
    void OnTrayContextMenuClick(QAction*);
private:
    Ui::MainWindow *ui;

    QPoint oldMousePos;
    bool isMousePressed = false;

    QProcess *process;
    QTimer *timer;

    qint64 uploadCount = 0,
    downloadCount = 0,
    oldUploadCount = 0,
    oldDownloadCount = 0;

    QSystemTrayIcon *trayIcon;

    void writeConfigInfo(); //写入配置信息
    void readConfigInfo(); //读取配置信息
    void OpenGnomeSystemMonitor(); //打开GnomeSystemMonitor
    void ReDealSizeInfo(QString *result);
};

#endif // MAINWINDOW_H
